package com.example.showImage;

import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;

import java.util.Optional;

public class AlertModel {
    public static Alert alert;

    /**
     * 下面两个函数原型罢了
     * @param str
     */
    public static void returnAlert(String str){
        alert=new Alert(Alert.AlertType.WARNING);
        alert.setTitle("Warning");
        alert.setHeaderText(null);
        alert.setContentText(str);
        alert.showAndWait();
    }

    /**
     * 是否到最后一张 yes==-1 no==0
     * @param str
     * @return
     */
    public static int returnAlertQuestion_ToLast(String str){
        alert=new Alert(Alert.AlertType.CONFIRMATION);
        alert.setTitle("提示");
        alert.setHeaderText(null);
        alert.setContentText(str+"");
        //alert.showAndWait();
        Optional<ButtonType> result = alert.showAndWait();
        if(result.get() == ButtonType.OK){
            return -1;
        }else{
            return 0;
        }
    }
    /**
     * 是否到第一张照片yes==1 no==0
     * @param str
     * @return
     */
    public static int returnAlertQuestion_ToFirst(String str){
        alert=new Alert(Alert.AlertType.CONFIRMATION);
        alert.setTitle("提示");
        alert.setHeaderText(null);
        alert.setContentText(str);
        //alert.showAndWait();
        Optional<ButtonType> result = alert.showAndWait();
        if(result.get() == ButtonType.OK){
            return 1;
        }else{
            return 0;
        }
    }


}
